package service.impl.v2;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import dao.v2.DicVOMapper;
import model.DicVO;
import model.GoodVO;
import service.v2.DicService;
import util.DateParseUtil;
@Service
public class DicServiceImpl implements DicService {
	@Autowired
	private DicVOMapper dao;

	public List<String> getChildrenNum(String loadPropertie) {
		return dao.getChildrenNum( loadPropertie);
	}
	public DicVO getDicById(String loadPropertie) {
		return dao. getDicById( loadPropertie) ;
	}
	@Cacheable(value="DicServiceImpl_getNameById",key="#root.targetClass+#root.methodName+#loadPropertie")
	public String getNameById(String loadPropertie) {
		return dao.getNameById(loadPropertie);
	}
	public String getLevelUpNameById(String loadPropertie) {
		return dao.getLevelUpNameById(loadPropertie);
	}
	public List<DicVO> getListByParent(String parent_id, GoodVO good) {
		List<DicVO> l = getDicListByParentId(parent_id);
		if("1".equals(good.getBond_type())){
			DicVO dicVO = new DicVO();
			dicVO.setName("保税仓发货");
			dicVO.setOther("本商品由友米乐保税仓发货");
			l.add(dicVO);
		}else if("2".equals(good.getBond_type())){
			DicVO dicVO = new DicVO();
			dicVO.setName("直邮仓发货");
			dicVO.setOther("本商品由直邮仓发货");
			l.add(dicVO);
		}
		return l;
	}
	
	@Cacheable(value="DicServiceImpl_getDicListByParentId",key="#root.targetClass+#root.methodName+#parent_id")
	public List<DicVO> getDicListByParentId(String parent_id){
		return dao.getListByParent(parent_id);
	}
	
	@Override
	public Map<String, String> getWord(String word, String parent_id) {
		return dao.getWord(word, parent_id);
	}
	@Override
	public String getNamEneById(String loadPropertie) {
		return dao.getNamEneById(loadPropertie);
	}
	@Override
	public List<String> getChildNamesByParent(String parent_id) {
		return dao.getChildNamesByParent(parent_id);
	}
}
